
import { BaseUrl } from "@/js/config.js";
import axios from 'axios';

export default class TransferService {
    constructor() {
        this.instance = axios.create({
            baseURL: BaseUrl,
            timeout: 240000,
            // withCredentials: true,
            headers: {
                // 'Access-Control-Allow-Credentials': 'true',
                // 'Access-Control-Allow-Origin': "*"
                // 'Access-Control-Allow-Origin': baseUrl
            },
            // httpsAgent: agent,
            // httpsAgent: new https.Agent({
            //     rejectUnauthorized: false,
            //     ca: 'yang wang'
            // })
        });
    }

    doTransfer(from, seed, to, amount) {
        // console.log(from, seed, to, amount);
        return this.instance.post("/transfer", { from, seed, to, amount });
        // this.instance.postJson("/transfer", { from, seed, to, amount });
        // this.instance.get("/transfer?from=" + from + "&seed=" + seed + "&to=" + to + "&amount=" + amount);
        // this.ajax.postJson("/transfer", { request });
    }

    doTransfer1(seed, tradeId, list) {
        // console.log(from, seed, to, amount);
        return this.instance.post("/transfer_request", { seed, tradeId, list });
        // this.instance.postJson("/transfer", { from, seed, to, amount });
        // this.instance.get("/transfer?from=" + from + "&seed=" + seed + "&to=" + to + "&amount=" + amount);
        // this.ajax.postJson("/transfer", { request });
    }

    queryTransfer(tradeId) {
        return this.instance.post("/transfer_query", { tradeId });
    }
}